import 'package:flutter/material.dart';
import './CaremaPage.dart';
import './DropDownPage.dart';
import './TipPage.dart';
import './ButtonPage.dart';
import './CheckBoxPage.dart';
import './TextField.dart';
import './RadioPage.dart';
import './SliderPage.dart';
import 'SwitchPage.dart';
import 'Animate.dart';
import 'AlignPage.dart';
import 'NavigationPage.dart';
import 'PicPage.dart';
import 'DrawerPage.dart';
import 'SearchPage.dart';
import 'RatePage.dart';
import 'CircleProgressPage.dart';
import 'CarouselPage.dart';
import 'StepperPage.dart';
import 'SelecterPage.dart';
import 'Native.dart';

class HomePage extends StatelessWidget {
  List<Map> list = [
    {
      'id': 'Button',
      'name': '按钮',
      'fun': (BuildContext context) => ButtonPage()
    },
    {
      'id': 'TextField',
      'name': '输入框',
      'fun': (BuildContext context) => TextFieldPage()
    },
    {
      'id': 'Dropdwon',
      'name': '下拉框',
      'fun': (BuildContext context) => DropDownPage()
    },
    {'id': 'Tip', 'name': '提示', 'fun': (BuildContext context) => TipPage()},
    {
      'id': 'CheckBox',
      'name': '选框',
      'fun': (BuildContext context) => CheckBoxPage()
    },
    {
      'id': 'Radio',
      'name': '单选框',
      'fun': (BuildContext context) => RadioPage()
    },
    {
      'id': 'Switch',
      'name': '切换按钮',
      'fun': (BuildContext context) => SwitchPage()
    },
    {
      'id': 'Slider',
      'name': '滑条',
      'fun': (BuildContext context) => SliderPage()
    },
    {'id': 'Align', 'name': '对齐', 'fun': (BuildContext context) => AlignPage()},
    {
      'id': 'Carema',
      'name': '相机',
      'fun': (BuildContext context) => CaremaPage()
    },
    {
      'id': 'Animate',
      'name': '动画',
      'fun': (BuildContext context) => AnimatePage()
    },
    {
      'id': 'Navigation',
      'name': '导航栏',
      'fun': (BuildContext context) => NavigationPage()
    },
    {'id': 'Pic', 'name': '图片展示', 'fun': (BuildContext context) => PicPage()},
    {
      'id': 'Drawer',
      'name': '侧边栏',
      'fun': (BuildContext context) => DrawerPage()
    },
    {
      'id': 'Search',
      'name': '搜索框',
      'fun': (BuildContext context) => SearchPage()
    },
    {'id': 'Rate', 'name': '评分', 'fun': (BuildContext context) => RatePage()},
    {
      'id': 'Carousel',
      'name': '走马灯',
      'fun': (BuildContext context) => CarouselPage()
    },
    {
      'id': 'CircleProgress',
      'name': '圆形进度条',
      'fun': (BuildContext context) => CircleProgressPage()
    },
    {
      'id': 'Stepper',
      'name': '步进器',
      'fun': (BuildContext context) => StepperPage()
    },
    {
      'id': 'Selecter',
      'name': '省市区地址选择器',
      'fun': (BuildContext context) => SelecterPage()
    },
    {
      'id': 'Native',
      'name': '原生交互',
      'fun': (BuildContext context) => NativePage()
    },
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('Demo列表'),
        ),
        body: ListView.separated(
          itemCount: list.length, //
          padding: const EdgeInsets.all(16.0),
          separatorBuilder: (BuildContext context, int index) => Divider(),
          itemBuilder: (context, i) {
            return ListTile(
              leading: Text(list[i]['id']),
              title: null,
              trailing: Text(list[i]['name']),
              onTap: () {
                Navigator.of(context)
                    .push(MaterialPageRoute(builder: list[i]['fun']));
              },
            );
          },
        ));
  }
}
